import 'package:flutter/material.dart';
import 'package:flutter_deer/account/models/user_score_deposit_entity.dart';
import 'package:flutter_deer/account/models/user_score_takeout_entity.dart';
import 'package:flutter_deer/widgets/state_layout.dart';

class BelowUserScoreListProvider extends ChangeNotifier {

  BelowUserScoreDepositPageEntity? _belowUserScoreDepositPage;
  List<BelowUserScoreDepositEntity>? _depositList = [];
  StateType? _depositStateType = StateType.loading;

  BelowUserScoreTakeoutPageEntity? _belowUserScoreTakeOutPage;
  List<BelowUserScoreTakeoutEntity>? _takeOutList = [];
  StateType? _takeOutStateType = StateType.loading;

  BelowUserScoreDepositPageEntity? get belowUserScoreDepositPage => _belowUserScoreDepositPage;
  int? get depositTotal => _belowUserScoreDepositPage!.total;
  int? get depositCurrent => _belowUserScoreDepositPage!.current;
  List<BelowUserScoreDepositEntity>? get depositRecords => _belowUserScoreDepositPage!.records;
  List<BelowUserScoreDepositEntity>? get depositList => _depositList;
  bool? get hasDepositMore => _depositList!.length<_belowUserScoreDepositPage!.total!;
  StateType? get depositStateType => _depositStateType;

  BelowUserScoreTakeoutPageEntity? get belowUserScoreTakeOutPage => _belowUserScoreTakeOutPage;
  int? get takeoutTotal => _belowUserScoreTakeOutPage!.total;
  int? get takeOutCurrent => _belowUserScoreTakeOutPage!.current;
  List<BelowUserScoreTakeoutEntity>? get takeOutRecords => _belowUserScoreTakeOutPage!.records;
  List<BelowUserScoreTakeoutEntity>? get takeOutList => _takeOutList;
  bool? get hasTakeOutMore => _takeOutList!.length<_belowUserScoreTakeOutPage!.total!;
  StateType? get takeOutStateType => _takeOutStateType;
  int? _currentPageDeposit = 1;
  int? _currentPageTakeOut = 1;
  int? get currentPageDeposit => _currentPageDeposit;
  int? get currentPageTakeOut => _currentPageTakeOut;

  void setBelowUserDepositScorePage(BelowUserScoreDepositPageEntity? pageEntity){
    this._belowUserScoreDepositPage = pageEntity;
    this._currentPageDeposit = pageEntity!.current;
    if(pageEntity.current==1) {
      this._depositList = pageEntity!.records;
    }else{
      for(int i=0;i<pageEntity.records!.length;i++){
        BelowUserScoreDepositEntity item = pageEntity.records!.elementAt(i);
        this._depositList!.add(item);
      }
    }
    this._depositStateType = StateType.takeOut;
    notifyListeners();
  }

  void setBelowUserTakeOutScorePage(BelowUserScoreTakeoutPageEntity? pageEntity){
    this._belowUserScoreTakeOutPage = pageEntity;
    this._currentPageTakeOut = pageEntity!.current;
    if(pageEntity.current==1) {
      this._takeOutList = pageEntity!.records;
    }else{
      for(int i=0;i<pageEntity.records!.length;i++){
        BelowUserScoreTakeoutEntity item = pageEntity.records!.elementAt(i);
        this._takeOutList!.add(item);
      }
    }
    this._takeOutStateType = StateType.takeOut;
    notifyListeners();
  }

}